package ace.cmp.spring.data.jdbc.querydsl.core.repository.handler.impl;

import ace.cmp.spring.data.jdbc.querydsl.core.QuerydslRelationHelper;
import ace.cmp.spring.data.jdbc.querydsl.core.model.PropertyRelation;
import ace.cmp.spring.data.jdbc.querydsl.core.repository.handler.QuerydslLogicDeleteGenerator;
import com.querydsl.core.types.Expression;

/**
 * @author caspar
 * @date 2024/6/26 16:03
 */
public class QuerydslLogicDeleteGeneratorImpl implements QuerydslLogicDeleteGenerator {

  private final QuerydslRelationHelper querydslRelationHelper;

  public QuerydslLogicDeleteGeneratorImpl(QuerydslRelationHelper querydslRelationHelper) {
    this.querydslRelationHelper = querydslRelationHelper;
  }

  @Override
  public Object generateNewValueNotDelete(Class entityClass, PropertyRelation propertyRelation) {
    return querydslRelationHelper.getLogicNotDeleteFlagValue(entityClass);
  }

  @Override
  public Expression generateNewExpression( Expression idExpression, Class entityClass, PropertyRelation propertyRelation) {
    return idExpression;
  }
}
